<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="@{include} :: header"></head>

<body class="gray-bg">
<div class="layuimini-container">
	<div class="layuimini-main">
		<div class="layui-row">
			<form class="layui-form layui-form-pane" id="signupForm">
				<input id="userId" name="userId" th:value="${user.userId}" type="hidden">
				<div class="layui-form-item">
					<label class="layui-form-label">输入密码：</label>
					<div class="layui-input-block">
						<input id="password" name="pwdNew" class="layui-input" type="password" value="">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block col-sm-offset-3">
						<button type="submit" class="layui-btn layui-btn-normal">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div th:include="include::footer"></div>
	<!-- 全局js -->
<!--	<script th:src="@{/js/jquery.min.js?v=2.1.4}"></script>-->
<!--	<script th:src="@{/js/bootstrap.min.js?v=3.3.6}"></script>-->

<!--	&lt;!&ndash; 自定义js &ndash;&gt;-->
<!--	<script th:src="@{/js/content.js?v=1.0.0}"></script>-->

<!--	&lt;!&ndash; jQuery Validation plugin javascript&ndash;&gt;-->
<!--	<script th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>-->
<!--	<script th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>-->


	<!-- script src="/js/demo/form-validate-demo.js}"></script> -->


	<script type="text/javascript">
		$(document).ready(function() {
			validateRule();
			//setCheckedRoles();
		});
		$.validator.setDefaults({
			submitHandler : function() {
				update();
			}
		});
		function update() {
			$.ajax({
				cache : true,
				type : "POST",
				url : ctx + "sys/user/adminResetPwd",
				data : $('#signupForm').serialize(),// 你的formid
				async : false,
				error : function(request) {
					parent.layer.msg("系统错误，联系管理员");
				},
				success : function(data) {
					if (data.code == 0) {
						parent.layer.msg(data.msg);
						parent.reLoad();
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
						parent.layer.close(index);

					} else {
						parent.layer.msg(data.msg);
					}

				}
			});

		}

		function validateRule() {
			var icon = "<i class='fa fa-times-circle'></i> ";
			$("#signupForm").validate({
				rules : {

					password : {
						required : true,
						minlength : 6
					}
				},
				messages : {
					password : {
						required : icon + "请输入您的密码",
						minlength : icon + "密码必须6个字符以上"
					}
				}
			})
		}
	</script>
</body>

</html>
